package com.kkshop.web.xwork2;

import java.text.MessageFormat;

import com.opensymphony.xwork2.ActionSupport;

public class AjaxActionSupport extends ActionSupport {

    private static final String RESPONSE_TEMPLATE =
        "<?xml version=\"1.0\"?>\n" +
        "<return>\n" +
        "  <code>{0}</code>\n" +
        "  <result>{1}</result>\n" +
        "</return>";
    
    private String code;
    private String result;
    
    protected String getCode() {
        return code;
    }
    
    protected void setCode(String code) {
        this.code = code;
    }
    
    protected String getResult() {
        return result;
    }
    
    protected void setResult(String result) {
        this.result = result;
    }
    
    protected String result(String code, String result) {
        setCode(code);
        setResult(result);
        return code;
    }
    
    public String getContent() {
        return MessageFormat.format(RESPONSE_TEMPLATE, getCode(), getResult());
    }
}
